const express = require('express');
require('dotenv').config()
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const logMiddleware = require('./middleware/logMiddleware');
const authMiddleware = require('./middleware/authMiddleware');
const routes = require('./routes/index');

const app = express();
app.use(cookieParser());
app.use(authMiddleware);
app.use(logMiddleware);
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));

routes.forEach((router) => {
    app.use("/", router);
});

module.exports = app;
